<?php
  function is_login(){
      if (session('?uid')) {
          return true;
      }else {
          return false;
      }
  }
  //通过伪路径获取图片真实路径
  function getImgpath($path){
      if ($path) {
          $paths = __ROOT__.'/Upload/img/'.$path;
      }else {
          $paths = __ROOT__.'/Upload/img/default/default.jpg';
      }
      return $paths;
  }
  //通过图片id获取图片真实路径
  function getImgidpath($id){
      if ($id) {
          $path = M('upload')->field('path')->find($id);
          $paths = getImgpath($path['path']);
      }else {
          $paths = __ROOT__.'/Upload/img/default/default.jpg';
      }
      return $paths;
  }

//随机字符串生成
function mdrand(){
    $code = '';
    $charset = '1234567890';
    $_len = strlen($charset) - 1;
    for ($i = 0;$i < 4;++$i) {
        $code .= $charset[mt_rand(0, $_len)];
    }
    return $code;
}

function check_verify($code, $id = ''){
    $verify = new \Think\Verify();
    return $verify->check($code, $id);
}



